mui.init({
//	preloadPages:[{
//		id:'mobile_mgrprotocol',
//		url:'mgrProtocol.html'
//	}]
});

mui.plusReady(function() {
	(function load(){
		var self=plus.webview.currentWebview();
		var loanRecordId =self.loanRecordId;
		var discountRate = self.discountRate;
		var fromUserId = self.fromUserId; 
//		var loanRecordId = plus.storage.getItem(KeyCfg.tran_loanRecordId);
//		var discountRate = plus.storage.getItem(KeyCfg.tran_discountRate);
		var url=UrlConfig.tranpro_load;
		var datas={loanRecordId:loanRecordId,discountRate:discountRate,fromUserId:fromUserId};
		$.ajax(url, {  
		        data : datas,  
		        dataType : 'jsonp',  
		        crossDomain: true,  
		        success: function(data) {
		        		data = JSON.parse(data);
		        		callback(data,self.fromType);
		        }
		    });
		
	})();
	/**
	 * 填充数据
	 * @param {Object} data
	 */
	function callback(data,fromType){
		var loanNumber= data["loanNumber"];
		var real_Name= data["real_Name"];
		var idcard= data["idcard"];
		var thisIssueLoan= data["thisIssueLoan"];
		var unReceiveMoney= data["unReceiveMoney"];
		var foreclosureFund= data["foreclosureFund"];
		var behoof= data["behoof"];
		var m_preRepayDate= data["m_preRepayDate"];
		var refundDeadline= data["refundDeadline"];
		var rephases= data["rephases"];
		var effective_yield= data["effective_yield"];
		var today = data["today"];
		var userName = plus.storage.getItem(KeyCfg.userName);
		var cardId= data["cardId"];
		var email = data["email"];
		var card= data["card"];
		var name = data["name"];
		var y_name = data["y_name"] || "";
		var y_idcard = data["y_idcard"] || "";
		var y_address = data["y_address"] || "";
		var y_email = data["y_email"] || "";
		$("#p_name").html("来理财用户名："+(fromType=='redeem'? '' : y_name));
		$("#p_cardId").html("身份证号码："+(fromType=='redeem'? '' : y_idcard));
		$("#p_address").html("住所："+ (fromType=='redeem'? '' : y_address));
		$("#p_email").html("电子邮件地址："+ (fromType=='redeem'? '' : y_email));
		$("#today").html(today);
        $("#loanNumber").html("编号: "+loanNumber);
		$("#real_Name").html("借款人姓名: "+real_Name);
		$("#idcard").html("借款人身份证号: "+idcard);
		$("#thisIssueLoan").html("初始借款金额:"+thisIssueLoan);
		$("#unReceiveMoney").html("本次转让债权价值: "+unReceiveMoney);
		$("#foreclosureFund").html("需支付对价: "+foreclosureFund);
		$("#behoof").html("借款人借款用途: "+behoof);
		$("#m_preRepayDate").html("还款起始日期 : "+m_preRepayDate);
		$("#refundDeadline").html("还款期限（月）: "+refundDeadline);
		$("#rephases").html("剩余还款数（月）: "+rephases);
		$("#effective_yield").html("预计债权收益率: "+effective_yield);
		var htmlArr =getJbHtml(data);
		var htmlStr = htmlArr.join(" ");
		$('#t_user').html(htmlStr);
	}
	
	function getJbHtml(data){
		var userName= data["userName"];
		var cardId = data["cardId"];
		var htmlArr = [
    		'<table border="1"  class="tab_cls">',
				'<tr >',
			  	'<td width="322" valign="center" style="text-align:center;"><p >来理财用户名 </p></td>',
			    '<td width="269" valign="center" style="text-align:center;" ><p >身份证号码 </p></td>',
	  			'</tr>',
	  			'<tr >',
			  	'<td width="322" valign="center"  style="text-align:center;"><p >'+userName+'</p></td>',
			    '<td width="269" valign="center"  style="text-align:center;"><p >'+cardId+' </p></td>',
	  			'</tr>',
			'</table>'
			];
			
			
	return htmlArr;
	}
});
